######################################
# 生成protobuf
######################################
pb_source = \
	config.proto

pb_target_h = $(addsuffix .pb.h, $(basename $(pb_source)))
pb_target_c = $(addsuffix .pb.c, $(basename $(pb_source))) 

pb_target =  $(pb_target_h) $(pb_target_c)
pb_includes = -I. -Ic/nanopb

build_dir = generated

.PHONY: c java python cpp go pb-clean typescript ts

c:
	protoc $(pb_includes) --nanopb_out=$(build_dir) $(pb_source)

java:
	protoc $(pb_includes) --java_out=$(build_dir) $(pb_source)

cpp:
	protoc $(pb_includes) --cpp_out=$(build_dir) $(pb_source)

python:
	protoc $(pb_includes) --python_out=$(build_dir) $(pb_source)

go:
	protoc $(pb_includes) --go_out=$(build_dir) $(pb_source)

typescript:
	protoc $(pb_includes) --plugin=typescript/node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=$(build_dir) $(pb_source)

ts: typescript

pb-clean:
	rm $(pb_target)

